package Leetcode.MapAndSet.uniqueMorseRepresentations804;

import java.util.Set;
import java.util.TreeSet;

public class Solution {
    public int uniqueMorseRepresentations(String[] words) {
        int len = words.length;
        String[] code = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};
        Set<String> result = new TreeSet<>();
        for (int i = 0; i < len; i++) {
            char[] word = words[i].toCharArray();
            StringBuilder string = new StringBuilder();
            for (char c : word) {
                string.append(code[c - 'a']);
            }
            System.out.println(string);
            result.add(string.toString());
        }
        return result.size();
    }

    public static void main(String[] args) {
        String[] strings = {"gin", "zen", "gig", "msg"};
        Solution solution = new Solution();
        System.out.println(solution.uniqueMorseRepresentations(strings));
    }
}
